package com.huatai.data.jdbc;

import java.sql.Types;
import java.util.Date;

/**
 * @author fanrui16
 */
public class JdbcObject {

    private Object object;

    private Integer type;

    private Class<?> clazz;

    public Object getObject() {
        return object;
    }

    public void setObject(Object object) {
        this.object = object;
        setClazz(object.getClass());
    }

    public Integer getType() {
        return type;
    }

    public void setType(Integer type) {
        this.type = type;
    }

    public Class<?> getClazz() {
        return clazz;
    }

    public void setClazz(Class<?> clazz) {
        this.clazz = clazz;
        if (clazz.equals(String.class)) {
            type = Types.VARCHAR;
        } else if (clazz.equals(Integer.class)) {
            type = Types.NUMERIC;
        } else if (clazz.equals(Double.class) || clazz.equals(Float.class)) {
            type = Types.NUMERIC;
        } else if (clazz.equals(Date.class)) {
            type = Types.DATE;
        }
    }

    @Override
    public String toString() {
        return "JdbcObject [object=" + object + ", type=" + type + ", clazz=" + clazz + "]";
    }

}
